
#include "EZLog.h"
#include "log.h"


void EZLog::init_logfile(const std::string& file)
{
	std::string nf = file + "_";
	time_t rawtime;
	struct tm  timeinfo;
	char buffer[80] = {};

	time(&rawtime);
#ifdef _WIN32
	localtime_s(&timeinfo,&rawtime);
#else
	localtime_r(&rawtime,&timeinfo);
#endif
	strftime(buffer, 80, "%Y-%m-%d", &timeinfo);
	nf += buffer;
	log_open(nf.c_str());
}


EZLog::~EZLog()
{
	log_write(level_, "%s", buf_.str().c_str());
	if (level_ == Logger::LEVEL_FATAL)
	{
		dump_stack();
		abort();
	}
}
